/*******************************************************************************
 * copyright (c) 2009 - 2010 Simon Allen
 *
 * This file is part of Convex Media Converter.
 *
 * Convex Media Converter is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Convex Media Converter is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with Convex Media Converter; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 ******************************************************************************/


#include "aboutdialog.h"

#include <QtGui>


/**
  * Produces 'about' dialog box with program/version/build/lisence information.
  *
  * \param parent Parent widget.
  * \sa ~AboutDialog()
  */
AboutDialog::AboutDialog(QWidget *parent): QDialog(parent), ui(new Ui::AboutDialog)
{
	ui->setupUi(this);

	setWindowIcon(QIcon(CONVEX_LOGO));

	connect(ui->buttonBox, SIGNAL(clicked(QAbstractButton *)),
		this, SLOT(hide()));

	QString version = "Version ";

	version += QString::number(CONVEX_VERSION_MAJOR) + ".";
	version += QString::number(CONVEX_VERSION_MINOR);

	ui->label_version->setText(version);
	ui->label_builtOn->setText("Built on " + QString(__DATE__) + " at " + QString(__TIME__));

	QPixmap icon = QPixmap(CONVEX_LOGO).scaledToWidth(100);
	QLabel *iconLabel = new QLabel(this);
	QHBoxLayout *iconBox = new QHBoxLayout(this);
	QSpacerItem *spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);

	iconLabel->setPixmap(icon);
	iconBox->addSpacerItem(spacer);
	iconBox->addWidget(iconLabel);
	iconBox->addSpacerItem(spacer);

	ui->verticalLayout->insertLayout(2, iconBox);
}

/** Deletes user interface class. */
AboutDialog::~AboutDialog()
{
	delete ui;

	ui = NULL;
}
